Skip to content

Refactor to transform a list of special keys into keycapborder visuals - #163

Open
bfritscher wants to merge 1 commit into
Code52:masterfrom
bfritscher:KeyCapBorder-for-all-special-keys
Open

bfritscher wants to merge 1 commit into
Code52:masterfrom
bfritscher:KeyCapBorder-for-all-special-keys

Conversation

@bfritscher

Copy link
Copy Markdown
Contributor

No description provided.

doggy8088 added a commit to doggy8088/carnac that referenced this pull request Oct 9, 2026
) (#6)

* Draw special keys as key caps from a single trigger

Replace the 24 near-identical per-key DataTriggers in KeyShowView with one
trigger driven by SpecialKeyConverter, backed by a unit-testable
SpecialKeys name set in Carnac.Logic. The set is also extended to the
keys that were still rendered as plain text (Caps Lock, Num Lock, Scroll
Lock, Print Screen, Pause, the context-menu key and F13-F24).

Based on the idea in Code52#163.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* Pin key cap names, move converter next to its sibling, add tests

Address review feedback:
- ReplaceKey now names the aliased keys explicitly (CapsLock, ScrollLock,
  PrintScreen, PageUp) so the key cap labels read properly and do not depend
  on which alias Enum.ToString() returns on a given runtime.
- SpecialKeyConverter moves to Utilities beside PlacementMarginConverter and
  declares its ValueConversion; the converter and the modifier names emitted
  by KeyProvider are now covered by tests.
- Restore the blank line and indentation around the Win trigger.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* Address second review round: CI compile fix, more key caps, labels

- Drop the converter test that referenced Binding.DoNothing (needs System.Xaml
  in the CI/legacy build) and the KeyProvider-based test that depended on the
  foreground window.
- Pin Return/Enter like the other aliased keys, label the context-menu key
  "Menu", and add Space (in shortcuts, e.g. Ctrl+Space), Cancel and Clear.
- Document why ReplaceKey names these keys explicitly.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* Label the context-menu key and Ctrl+Break, cover Shift+Space

- "Menu" is the Alt key's Keys member (VK_MENU), so ReplaceKey.ToKey("Menu")
  would not resolve to the context-menu key: label it "ContextMenu".
- Ctrl+Break is Keys.Cancel; show it as "Break", the label on the key.
- Treat any multi-part input as a shortcut when formatting, so Shift+Space
  draws a Space key cap like Ctrl+Space does.
- Note in the XAML and in SpecialKeys that Return and Win have their own
  triggers.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* Keep Shift+Space as it was, guard the Return/Win invariant

Treating every multi-part input as a shortcut also turned the space typed
with Shift held ("HELLO WORLD") into a Shift + Space key cap in the middle of
a sentence. Revert that: Space is a key cap in Ctrl/Alt/Win shortcuts only.

Also explain in ReplaceKey that the table is read by ToKey too, test that the
Break label resolves to Ctrl+Break for the keymaps, and pin that Return and
Win stay out of SpecialKeys because they have their own triggers.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* Tidy the key cap set and its tests after review

- Clear is no longer a key cap: with NumLock off it is what the 5 on the numpad
  types, and a "Clear" cap in the middle of a number is a surprise.
- The keymap test now covers only the names that resolve through the table
  (the names that are members of Keys parse with Enum.TryParse whatever the
  table says), and the duplicate Break assertion is gone.
- The closing tag of the triggers lines up with the opening one.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* Restore the tests for what is not a key cap

They were removed by mistake together with a duplicate assertion: text that has
to stay plain (wrong case, F0/F25, Clear, separators, arrows) and a typed space.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-authored-by: merge check <merge-check@example.invalid>
@doggy8088

Copy link
Copy Markdown

Hi there! 👋

I (@doggy8088 / Will Huang) have stepped in to take over active maintenance of Carnac at doggy8088/carnac (project website: https://carnac.gh.miniasp.com/).

Thank you @bfritscher for contributing this refactoring PR to transform special keys into keycap border visuals! 🎉

Context & What Changed

Availability

  • Source Code: Available now on the dev branch of doggy8088/carnac.
  • Upcoming Release: This will be included in the next official release, which will be published to GitHub Releases (both installer and portable .zip), WinGet (winget install doggy8088.Carnac), and Chocolatey.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants